package com.demo.mapper;

import com.demo.model.NewUser;
import org.apache.flink.streaming.connectors.redis.common.mapper.RedisCommand;
import org.apache.flink.streaming.connectors.redis.common.mapper.RedisCommandDescription;
import org.apache.flink.streaming.connectors.redis.common.mapper.RedisMapper;

/**
 * 仅构建新增用户的HLL，HLL的值需要具体服务按需通过对应的key查询
 *
 */
public class NewUserRedisMapper implements RedisMapper<NewUser> {

  /**
   * 执行的redis操作命令
   * @return RedisCommandDescription
   */
  @Override
  public RedisCommandDescription getCommandDescription() {
    return new RedisCommandDescription(RedisCommand.PFADD);
  }

  @Override
  public String getKeyFromData(NewUser data) {
    return data.getDist_key();
  }

  @Override
  public String getValueFromData(NewUser data) {
    return data.getUser_id();
  }

}
